Skip to content

fix(web): track transaction completion and connection lifetime - #1334

Open
OskarEichler wants to merge 4 commits into
react-native-async-storage:mainfrom
OskarEichler:codex/asyncstorage-indexeddb
Open

fix(web): track transaction completion and connection lifetime#1334
OskarEichler wants to merge 4 commits into
react-native-async-storage:mainfrom
OskarEichler:codex/asyncstorage-indexeddb

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Propagate open/transaction failures through caller promises, wait for deletion commit, close blocking connections and discard terminated connections.

Compatibility / observable behavior

removeMany now rejects when its transaction aborts. Version-change requests close the old connection; later calls reopen (and reject normally if another client upgraded beyond version 1). Blocked opens wait through IndexedDB instead of throwing from an unrelated event callback.

Related to #1331. This is a focused part of a source review; it does not claim the entire repository is bug-free.

Test Plan

  • Real idb 8.0.3 with fake-indexeddb: failed-open retry, get/put/delete aborts, rollback, empty batches, normal CRUD, forced termination and external database deletion. Baseline has unhandled rejections, resolves an aborted deletion, reuses a closed database and prevents external deletion; fixed handles all cases.
  • Upstream yarn build:js, yarn test:ts (6 tasks), yarn test:lint (6 tasks), yarn test:format and git diff --check pass on the combined review checkout.
  • No checked-in test/spec files changed. Reproductions were isolated and used synthetic data, not production/user storage.
  • The combined 3.1.1 backport passes consumer immutable install/lint, both products' Android Debug and iOS Simulator Debug builds, four production Metro bundles, 13 web targets and four browser-extension targets. Published native framework binaries are unchanged. React Doctor: 100/100.
  • Shared-storage testAndroidHostTest, macosArm64Test and iosSimulatorArm64Test pass with Java 21. The first Android run used Java 17 and failed Robolectric's SDK 36/JDK check; rerunning with the project's documented JDK fixed the environment failure without a source workaround.
  • Windows/WinRT runtime, signed releases and physical-device behavior have not been verified locally.

@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3565f98

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@react-native-async-storage/async-storage Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@krizzu krizzu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change removes thrown errors that are meaningful to user. I would rather throw an error, than silently fail with no info

@OskarEichler

Copy link
Copy Markdown
Contributor Author

Agreed that callers should retain meaningful failure information. I restored the typed WebStorageError from the blocked callback while keeping blocking as an active lifecycle response: the existing connection closes on versionchange, which is what lets the pending upgrade proceed instead of leaving it silently blocked. I also ran the repository formatter over both touched storage files. The package build and TypeScript check pass; the checked-in tree currently has no ESLint config discoverable by its ESLint 9 package script, so that local lint command cannot initialize.

@krizzu

krizzu commented Aug 31, 2026

Copy link
Copy Markdown
Member

as an active lifecycle response: the existing connection closes on versionchange, which is what lets the pending upgrade proceed instead of leaving it silently blocked.

Yes, that's true, I believe this is also a good thing to give feedback to consumer about this happening anyway, so throwing an error in order to retry would make sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants